package com.linsir.user;

import com.linsir.common.Easy;
import com.linsir.common.base.BaseController;
import com.linsir.common.utils.EncryptUtil;
import com.linsir.common.utils.xx;
import com.linsir.model.User;

/**
 * @author linsir
 * @title: UserController
 * @projectName linsir-mu
 * @description: 自定义用户管理
 * @date 2021/12/3 23:23
 */
public class UserController extends BaseController {
    // 修改密码
    public void pwd() {
        Integer id = xx.toInt(getSelectValue("id"));
        String val = getInputValue();

        if (xx.isEmpty(val)) {
            renderJson(new Easy("密码不能为空！"));
            return;
        }
        if (val.length() < 6) {
            renderJson(new Easy("密码不能少于6位！"));
            return;
        }

        User user = new User();
        user.set("id", id);
        user.set("login_pwd", EncryptUtil.getSM32(val));
        user.update();

        renderJson(new Easy());
    }
}
